var _openId = null;
$(function() {
	_openId = qmsk.getQueryValue("openId");
	$("#noData").hide();
	$("#more").unbind('click');
	$("#more").bind("click", function() {
		qmsk.redirectUrl("moreSubscribe.html", {
			openId : _openId
		});
	});
	loadList();
});

function loadList() {
	qmsk.get("../../../customerMessageType/list/" + _openId, {
		flag : 'flag'
	}, function(response) {
		printDataToPage(response);
	});
}

function printDataToPage(response) {
	$("#followBox").empty();
	var row = response.row;
	if (!row || row == 0) {
		$("#noData").show();
		return;
	}
	$("#noData").hide();

	for (var i = 0; i < row; i++) {
		//"typeId","typeName","description","flag"
		var typeId = response.getValue('typeId', i);
		var typeName = response.getValue('typeName', i);
		var description = response.getValue('description', i);

		$div = $("<div class='follow'></div>");
		$div.appendTo($("#followBox"));
		$("<h3>" + typeName + "</h3>").appendTo($div);
		$("<p>" + description + "</p>").appendTo($div);
		$("<a href='javascript:void(0)' onClick='unbind(" + typeId + ")' class='delBtn'>取消订阅</a>").appendTo($div);
	}

}

function unbind(typeId) {

	qmsk.post('../../../customerMessageType/unbind/' + _openId + '/' + typeId, function() {
		loadList();
		alert("取消关注成功！");
	});

}
